package com.chatsystem.util;

import io.jsonwebtoken.security.Keys;
import javax.crypto.SecretKey;
import java.util.Base64;

/**
 * JWT密钥生成工具
 * 用于生成安全的JWT密钥
 * 
 * @author ChatSystem
 * @version 1.0.0
 */
public class JwtKeyGenerator {

    public static void main(String[] args) {
        // 生成安全的JWT密钥
        SecretKey key = Keys.secretKeyFor(io.jsonwebtoken.SignatureAlgorithm.HS512);
        
        // 将密钥转换为Base64编码的字符串
        String secretKey = Base64.getEncoder().encodeToString(key.getEncoded());
        
        System.out.println("生成的JWT密钥:");
        System.out.println(secretKey);
        System.out.println();
        System.out.println("密钥长度: " + secretKey.length() + " 字符");
        System.out.println("密钥字节长度: " + key.getEncoded().length + " 字节");
        System.out.println();
        System.out.println("在application.yml中使用:");
        System.out.println("jwt:");
        System.out.println("  secret: " + secretKey);
        System.out.println("  expiration: 86400000");
    }
} 